import os
from random import shuffle

train = open('train.txt', mode='w')
val = open('val.txt', mode='w')
test = open('test.txt', mode='w')
trainval = open('trainval.txt', mode='w')

imagePath = "F:\学习\数据集\实验室数据集操作版\性诱\性诱网站下载221026\标注"

images=os.listdir(imagePath)
imageLen=len(images)
shuffle(images)
for i in range(imageLen):
    if i<imageLen*0.7:
        train.write(images[i]+'\n')  # \n 换行符
        trainval.write(images[i] + '\n')  # \n 换行符
    elif i<imageLen*0.9:
        val.write(images[i] + '\n')  # \n 换行符
        trainval.write(images[i] + '\n')  # \n 换行符
    else:
        test.write(images[i] + '\n')  # \n 换行符
train.close()
val.close()
test.close()
trainval.close()
